#define _CRT_SECURE_NO_WARNINGS 
#include <stdio.h>
struct apple {
	int x, y;
}q[5000];
void QuickSort(struct apple* q, int low, int high) {
	if (low < high) {
		int i = low;
		int j = high;
		int key = q[low].y;
		int qwe = q[low].x;
		while (i < j) {
			while (i < j && q[j].y >= key)
				j--;
			if (i < j)
				q[i++] = q[j];
			while (i < j && q[i].y < key)
				i++;
			if (i < j)
				q[j--] = q[i];			
		}
		q[i].y = key;
		q[i].x = qwe;
		QuickSort(q, low, i - 1);
		QuickSort(q, i + 1, high);
	}
}
int main()
{
	int n, s;
	scanf("%d%d", &n, &s);
	int a, b;
	scanf("%d%d", &a, &b);
	for (int i = 0; i < n; i++)
	{
		scanf("%d%d", &q[i].x, &q[i].y);
	}
	QuickSort(q, 0, n - 1);
	int sum = 0;
	for (int i = 0; i < n; i++)
	{
		if (s < q[i].y)
		{
			break;
		}
		if (s > q[i].y && a + b >= q[i].x)
		{
			s -= q[i].y;
			sum++;
		}
	}
	printf("%d", sum);
	return 0;
}